import * as types from './types';
//import {lcstore} from '../../util/';
import lcstore from "../../util/store";
var time = 60 * 60;
export default {
  //更新用户信息
  [types.UPDATE_USERINFO](state, user_db) {
    state.userinfo = user_db.userinfo || {};
    let exp = state.userinfo.expDate || time + '';

    state.userinfo.expDate = exp + '';

    console.log("过期时间：" + exp);
    lcstore.setExp('userinfo', state.userinfo, exp);
  },
  //更新用户头像
  [types.UPDATE_USERPIC](state, picurl) {
    state.userinfo.pictContent = picurl || '';
    let exp = state.userinfo.expDate || time;
    lcstore.setExp('userinfo', state.userinfo, exp);
  },
  //更新VIP
  [types.UPDATE_VIP](state, vip) {
    state.userinfo.isvip = vip || '0';
    let exp = state.userinfo.expDate || time;
    lcstore.setExp('userinfo', state.userinfo, exp);
  },
  //更新真实姓名
  [types.UPDATE_REALNAME](state, realName) {
    state.userinfo.realName = realName || '';
    let exp = state.userinfo.expDate || time;
    lcstore.setExp('userinfo', state.userinfo, exp);
  },
  //清空用户信息
  [types.REMOVE_USERINFO](state) {
    lcstore.remove('userinfo');
    state.userinfo = {};
  },
  //更新记录密码相关信息
  [types.UPDATE_REMUMBER](state, user_db) {
    state.remumber.remumber_flag = user_db.remumber_flag;
    state.remumber.remumber_login_info = user_db.remumber_login_info;

    store.set('remumber_flag', state.remumber.remumber_flag);
    store.set('remumber_login_info', state.remumber.remumber_login_info);
  },
  //清空记录密码相关信息
  [types.REMOVE_REMUMBER](state) {
    store.remove('remumber_flag');
    store.remove('remumber_login_info');

    state.remumber.remumber_flag = false;
    state.remumber.remumber_login_info = {
      username: '',
      token: ''
    };
  },
}
